<div data-role="content" class="jqm-content">
    <div data-role="collapsible-set" data-theme="c" data-content-theme="f">
        <?php foreach ($dates as $key => $date) { ?>
            <div data-role="collapsible">
                <h3><?php echo $key; ?> </h3>

                <ul data-role="listview" data-inset="false">
                    <!--    ======popup============   -->

                    <div data-role="collapsible-set" data-inset="">
                        <a href="#popupDialog<?php echo $key; ?>" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-transition="pop" data-icon="grid" data-iconpos="notext" data-theme="c" data-inline="true" >Tính tiền</a>
                        <div data-role="popup" id="popupDialog<?php echo $key; ?>" data-overlay-theme="a" data-theme="c" data-dismissible="true" style="max-width:90%; width: 700px;" class="ui-corner-all">
                            <div data-role="header" data-theme="a" class="ui-corner-top">
                                <h1>Money: <?php echo $key; ?></h1>
                            </div>
                            <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
                                <!--                list =============-->
                                <div style="padding-bottom: 10px">
                                    <?php
                                    $total = 0;
                                    foreach ($money[$key] as $memberId => $mon) {
                                        if ($memberId > 0)
                                            $total += $mon;
                                    }
                                    ?>

                                    TOTAL:
                                    <span style="color: red"><?php echo Yii::app()->numberFormatter->formatCurrency($total, 'VND'); ?>
                                    </span>
                                </div>

                                <table data-role="table" id="table-column-toggle" data-mode="" class="ui-responsive table-stroke">
                                    <thead>
                                        <tr>
                                            <th data-priority="2">Name</th>
                                            <th>Win</th>
                                            <th data-priority="3">Lost</th>
                                            <th data-priority="1"><abbr title="Rotten Tomato Rating">Money</abbr></th>
                                        </tr>
                                    </thead>
                                    <tbody style="font-weight: normal">
                                        <?php foreach ($money[$key] as $memberId => $mon) { ?>
                                            <?php if ($memberId > 0) { ?>

                                                <tr>
                                                    <th style="font-weight: normal"><?php echo $members[$memberId]; ?></th>
                                                    <td style="font-weight: normal"><?php echo $win[$key][$memberId]; ?></td>
                                                    <td style="font-weight: normal"><?php echo $lost[$key][$memberId]; ?></td>
                                                    <td style="font-weight: normal<?php if ($mon > 0) echo '; color: red' ?>">
                                                        <?php echo Yii::app()->NumberFormatter->format("$ #,##0", $mon, 'VND'); ?>
                                                    </td>

                                                </tr>
                                            <?php } ?>
                                        <?php } ?>
                                    </tbody>

                                </table>
                                <!--                list =============-->
                                <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="c">Cancel</a>

                            </div>
                        </div>
                        </
                        <!--    ==================   -->

                        <!-- ===============grid=============== -->
                        <?php
                        foreach ($date as $id => $match) {
                            //singer check
                            if (!$match['member_name_win_1'] || !$match['member_name_win_2'] || !$match['member_name_lost_1'] || !$match['member_name_lost_2']) {
                                $singerFlag = 1;
                            } else {
                                $singerFlag = 2;
                            }
                            ?>
                            <li style="margin: 5px 5px">
                                <div class="ui-grid-b ui-responsive" style="font-weight: normal">
                                    <div class="ui-block-a"><div class="ui-body ui-body-d" style="text-align: left"><?php echo "{$match['member_name_win_1']} - {$match['member_name_win_2']} ({$match['match_point_win']}) "; ?></div></div>
                                    <div class="ui-block-b"><div class="ui-body ui-body-d" style="text-align: right"><?php echo "({$match['match_point_lost']}) {$match['member_name_lost_1']} - {$match['member_name_lost_2']}"; ?></div></div>
                                    <div class="ui-block-c">
                                        <div class="ui-body ui-body-d" style="text-align: right; "><?php echo Yii::app()->NumberFormatter->format("$ #,##0", $match['match_price'] * $singerFlag, 'VND') ?>
                                            <?php if ($key == date('Y-m-d')): ?>
                                            <a class="del" data-transition="pop" href="<?php echo Yii::app()->createUrl('intro/del', array('matchId'=>$id)); ?>" h="<?php echo $id ?>" match_id="<?php echo $id ?>"> | Delete.</a>
                                            <?php endif; ?>

                                        </div>

                                    </div>
                                </div><!-- /grid-a -->

                            </li>
                        <?php } ?>
                        <!-- ===============grid=============== -->
                </ul>
            </div>
        <?php } ?>
    </div>


</div><!-- /content -->
<div data-role="popup" id="popupDialogDel" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:400px;" class="ui-corner-all">
    <div data-role="header" data-theme="a" class="ui-corner-top">
        <h1>Delete match</h1>
    </div>
    <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
        <h3 class="ui-title">Are you sure!</p>
            <a id="btn_del" href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b" match_id="">Delete</a>
            <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="c">Cancel</a>
            <input type="hidden" value="" id="input_del"/>
    </div>
</div>
<script>
    $(document).ready(function() {
        $('.del').click(function() {
            var r = confirm("Có chắc muốn xóa không em?");
            if (r == true)
              {
              x = "You pressed OK!";
              }
            else
              {
              return false;
              }
        });
    });

</script>